1.Why?Fflush (stdin)If yes, first check the following program: # includeStdio. h>Int main (void) {int I; for (;) {fputs ("Please input an integer:", stdout); scanf ("% d", & I ); printf ("% d/N", I);} return 0;} this program will first prompt the
1. Why is fflush (stdin) incorrect?
First, check the following program:
# Include
Int main (void)
{
Int I;
For (;;){
Fputs ("Please input an integer:", stdout );
Scanf ("% d", & I );
Printf ("% d/N", I );
}
Return 0;
}
This program will
1.Why?
Fflush (stdin)Yes
First, check the following program:
# IncludeStdio. h>
Int main (void)
{
Int I;
For (;;){
Fputs ("Please input an integer:", stdout );
Scanf ("% d", & I );
Printf ("% d/N", I );
}
Return 0;
}
This program will first
1. Why is fflush (stdin) incorrect?
First, check the following program:
# Include Int main (void){Int I;
For (;;){Fputs ("Please input an integer:", stdout );Scanf ("% d", & I );Printf ("% d/N", I );}
Return 0;}
This program will first prompt the
1.Why?Fflush (stdin)Yes
First, check the following program:
# IncludeStdio. h>
Int main (void)
{
Int I;
For (;;){
Fputs ("Please input an integer:", stdout );
Scanf ("% d", & I );
Printf ("% d \ n", I );
}
Return 0;
}
This program will first
1. buffered I/O, that is, standard I/O
First, it should be clear that unbuffered I/O is only relative to buffered I/O, that is, standard I/O.
Instead of using unbuffered I/O to read and write data to a disk, there is no buffer. In fact, the kernel
Reprinted from: http://blog.chinaunix.net/u3/99423/showart_2100968.html
I have made many mistakes in the scanf function, and I have also seen mistakes made by others. Remember to remind myself not to repeat the same mistakes. If it is useful to you,
Clear the cache in stdin
Int C;
While (C = getchar ())! = EOF & C! = '\ N ');
The cache is cleared, but '\ n' (10) is left behind)
When reading, you can use scanf ("% [^ \ n]", c); To empty \ n.
Or scanf ("\ n % d", C );
Failed
Two original posts: http://www.cnblogs.com/younes/archive/2010/01/05/1639482.html
Http://blog.csdn.net/cxyol/archive/2006/03/18/628324.aspx
FirstTwo functions are not functions in the c Standard Library:
Int getch (void) // read a character from
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.